
const path = require("path");
function resolve(dir) {
  return path.join(__dirname, dir)
}
module.exports = {
    // 网页标题
    // chainWebpack: (config) => {
    //   config.plugin("html").tap((args) => {
    //     args[0].title = "广发证券系统";
    //     return args;
    //   });
    // },
    // 全局路径
    configureWebpack: {
      resolve: {
        alias: {
          "@": path.resolve(__dirname, "src"),
        },
      },
    },
    productionSourceMap: false,
    publicPath: process.env.NODE_ENV === "production" ? "/" : "/",
    outputDir: 'dist',
    assetsDir: 'assets',
    devServer: {
      port: 81,
      host: '0.0.0.0',
      https: false,
      open: true,
      proxy: {
        [process.env.VUE_APP_BASE_API]: {
          target: process.env.VUE_APP_PROXY,
          changeOrigin: true,
          pathRewrite: {
            ['^' + process.env.VUE_APP_BASE_API]: ''
          }
        },
          '/eam_poc':{
              target: `localhost:8888`,
              changeOrigin: true,
              ws:true,
              pathRewrite:{
                  '^/eam_poc' : '' // 重写请求
              }
          }
      },
      client: {
        overlay: false,
        logging: 'info',
      },
      hot: false, // 禁用热加载
    },
    chainWebpack(config) {
      config.plugin("html").tap((args) => {
        args[0].title = "广发资产管理系统POC";
        return args;
      })
      // set svg-sprite-loader
      config.module
        .rule('svg')
        .exclude.add(resolve('src/assets/icons'))
        .end()
      config.module
        .rule('icons')
        .test(/\.svg$/)
        .include.add(resolve('src/assets/icons'))
        .end()
        .use('svg-sprite-loader')
        .loader('svg-sprite-loader')
        .options({
          symbolId: 'icon-[name]'
        })
        .end()

      // set preserveWhitespace
      config.module
        .rule('vue')
        .use('vue-loader')
        .loader('vue-loader')
        .tap(options => {
          options.compilerOptions.preserveWhitespace = true
          return options
        })
        .end()
      allowedHosts: "all"
    }
}

